Skip to content

Comments

feat(SectionCampaign): add title-selector attribute for customizable title injection#1032

Merged
timowestnosto merged 7 commits intomainfrom
copilot/customize-title-injection
Feb 19, 2026
Merged

feat(SectionCampaign): add title-selector attribute for customizable title injection#1032
timowestnosto merged 7 commits intomainfrom
copilot/customize-title-injection

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Context

Adds a title-selector attribute to SectionCampaign component to enable customizable title injection. When provided, the component will inject the campaign title into the element matching the specified CSS selector. Title injection only occurs when the attribute is explicitly provided.

Related Jira ticket

N/A

Screenshots

N/A


Changes:

  • Added optional titleSelector property to SectionCampaign component
  • Title injection only occurs when title-selector attribute is explicitly provided
  • Updated JSDoc with attribute name mapping (title-selector)
  • Added comprehensive test coverage for custom selector usage and default behavior (no injection)

Usage:

<!-- No title injection (default behavior) -->
<nosto-section-campaign placement="hero" section="featured"></nosto-section-campaign>

<!-- Title injection with custom selector -->
<nosto-section-campaign 
  placement="hero" 
  section="featured" 
  title-selector=".my-custom-title">
</nosto-section-campaign>

Note: Title injection is opt-in and only occurs when the title-selector attribute is provided. The titleSelector property expects a valid CSS selector; invalid selectors will throw a DOMException as per standard DOM behavior.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: timowestnosto <13622115+timowestnosto@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for customizable title injection in SectionCampaign feat(SectionCampaign): add title-selector attribute for customizable title injection Feb 18, 2026
Copilot AI requested a review from timowestnosto February 18, 2026 10:07
@timowestnosto timowestnosto marked this pull request as ready for review February 18, 2026 10:09
Copilot AI review requested due to automatic review settings February 18, 2026 10:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a title-selector attribute to nosto-section-campaign so consumers can control which heading element receives the injected campaign title, while keeping the existing .nosto-title default behavior.

Changes:

  • Introduced optional titleSelector (title-selector) attribute/property on SectionCampaign.
  • Updated title injection to use this.titleSelector || ".nosto-title" for backward-compatible behavior.
  • Added tests for custom selector usage and default selector fallback.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/components/SectionCampaign/SectionCampaign.ts Adds titleSelector support and uses it to locate the heading element for title injection.
test/components/SectionCampaign/SectionCampaign.spec.tsx Adds coverage for custom title-selector and verifies default .nosto-title behavior remains intact.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: timowestnosto <13622115+timowestnosto@users.noreply.github.com>
Copilot AI changed the title feat(SectionCampaign): add title-selector attribute for customizable title injection feat(SectionCampaign): add opt-in title-selector attribute for title injection Feb 19, 2026
Copilot AI requested a review from timowestnosto February 19, 2026 11:03
*
* @property {string} placement - The placement identifier for the campaign.
* @property {string} section - The section to be used for Section Rendering API based rendering.
* @property {string} [titleSelector] - CSS selector for the title element to inject the campaign title (attribute: "title-selector"). If not provided, no title injection will be performed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot drop second sentence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the second sentence from the JSDoc. (157041d)

Co-authored-by: timowestnosto <13622115+timowestnosto@users.noreply.github.com>
Co-authored-by: timowestnosto <13622115+timowestnosto@users.noreply.github.com>
Copilot AI changed the title feat(SectionCampaign): add opt-in title-selector attribute for title injection feat(SectionCampaign): add title-selector attribute for customizable title injection Feb 19, 2026
@timowestnosto timowestnosto merged commit 614daa9 into main Feb 19, 2026
3 checks passed
@nosto-release-public
Copy link

🎉 This PR is included in version 11.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants